package com.xbongbong.saas.enums.mini;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import lombok.Getter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 应用模块名称<p>
 * 代码描述<p>
 * Company: 逍邦网络科技有限公司<p>
 *
 * @author chenshan
 * @version v1.0
 * @since 2020/9/3 1:41 下午
 */
@Getter
@ToString
public enum DingRobotManagePushEnum {
    
    PERFORMANCE_RANKING(1,"performance_ranking","业绩排行推送",1,1,"18:00","18:05","以当天截止统计时间的数据为准"),
    CLINCH_DEAL_CONTRACT(2,"clinch_deal_contract","合同成交推送",1,0,"","","合同订单创建后即时推送"),
    MOST_ORDERS(3,"most_orders","打单王者喜报推送",1,1,"18:00","18:05","以当天截止统计时间的数据为准"),
    MAX_ORDER_AMOUNT(4,"max_order_amount","成交王者喜报推送",1,1,"18:00","18:05","以当天截止统计时间的数据为准"),
    VISITORS_TO_PLAN(5,"visitors_to_plan","访客计划推送",1,0,"","","访客计划创建后即时推送"),
    /**
     * 未知规则,当异常时用于返回
     */
    UNKNOWN(404, "","",0,0,"","",""),
    ;
    
    private Integer code;
    
    private String alias;
    
    private String name;
    
    private Integer enable;
    
    private Integer setUp;
    
    private String staticsTime;
    
    private String pushTime;
    
    private String memo;
    
    DingRobotManagePushEnum(Integer code, String alias, String name, Integer enable, Integer setUp,String staticsTime,String pushTime,String memo){
        this.code = code;
        this.alias = alias;
        this.name= name;
        this.enable = enable;
        this.setUp = setUp;
        this.staticsTime = staticsTime;
        this.pushTime = pushTime;
        this.memo = memo;
    }
    
    public static DingRobotManagePushEnum getByCode(Integer code) {
        for ( DingRobotManagePushEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
    
    public static List<DingRobotManagePushEnum> getAllEnum() {
        List<DingRobotManagePushEnum> managePushEnumList = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for ( DingRobotManagePushEnum cacheCode : values()) {
            if (cacheCode == UNKNOWN) {
                continue;
            }
            managePushEnumList.add(cacheCode);
        }
        return managePushEnumList;
    }
    
    public static Map<String,DingRobotManagePushEnum> getAllMap() {
        Map<String,DingRobotManagePushEnum> managePushEnumMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for ( DingRobotManagePushEnum cacheCode : values()) {
            if (cacheCode == UNKNOWN) {
                continue;
            }
            managePushEnumMap.put(cacheCode.getAlias(),cacheCode);
        }
        return managePushEnumMap;
    }

    public static DingRobotManagePushEnum getByAlias(String alias) {
        for (DingRobotManagePushEnum cacheCode : values()) {
            if (cacheCode.getAlias().equals(alias)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
    
    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
    
    public String getDescribe() {
        return I18nMessageUtil.getMessage(memo);
    }
}
